package org.bzjj.servlet.update;

import java.io.IOException;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import org.apache.log4j.Logger;
import org.bzjj.log.MyLog;
import org.bzjj.servlet.bean.CarErr;
import org.bzjj.servlet.bean.ctrl.TuiBan;
import org.bzjj.tool.ChatMethod;
import org.bzjj.tool.TmriXmlUtil;

public class CarRejectUpdate extends HttpServlet {

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;

	public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {

		String jylsh = request.getParameter("jylsh");
		String hpzl = request.getParameter("hpzl");
		String hphm = request.getParameter("hphm");

		TuiBan test = new TuiBan();
		CarErr carErr = null;
		try {
			String str = test.doQuery(jylsh, hphm, hpzl);
			carErr = (CarErr) TmriXmlUtil.parseUTF8XML2Bean(str, "org.bzjj.servlet.bean.CarErr", "head");
		} catch (Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}

		if (carErr == null) {
			ChatMethod.setResponse(response, "系统异常");
			return;
		} else if (carErr.getCode().equals("1")) {
			
			HttpSession session = request.getSession();
			String ip=request.getRemoteAddr();
			String user=(String) session.getAttribute("username");
			Logger logger = MyLog.getLog("CarRejectUpdate");
			logger.info("退办:"+user+"--"+ip+"--"+jylsh+"--"+hphm+"--"+hpzl);
			
			ChatMethod.setResponse(response, "1");
			return;
		} else {
			ChatMethod.setResponse(response, carErr.getMessage());
			return;
		}

	}
}
